//
//  ReleaseServerCollectionViewCell.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/6/11.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "ReleaseServerCollectionViewCell.h"
@interface ReleaseServerCollectionViewCell()
@property(nonatomic, strong) UIImageView *imageView;
@property(nonatomic, strong) UILabel *titleLabel;
@end

@implementation ReleaseServerCollectionViewCell
- (void)setDataDic:(NSDictionary *)dataDic
{
    NSString *str = dataDic[@"catico"];
    if (str.length > 0) {
        [self.imageView sd_setImageWithURL:[NSURL URLWithString:dataDic[@"catico"]]];
    }
    self.titleLabel.text = dataDic[@"catname"];
    
}
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpViews];
    }
    return self;
}

- (void)setUpViews
{
    [self addSubview:self.imageView];
    [self addSubview:self.titleLabel];
    
    __weak typeof(self)weakself = self;
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakself);
        make.centerX.equalTo(weakself.mas_centerX);
        make.width.height.mas_equalTo(40 / WIDTH_6S_SCALE);
    }];
    self.imageView.layer.cornerRadius = 20 / WIDTH_6S_SCALE;
    self.imageView.layer.masksToBounds = YES;
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakself.imageView.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
        make.left.right.equalTo(weakself);
        make.height.mas_equalTo(20);
    }];
}
#pragma mark - init
- (UIImageView *)imageView
{
    if (!_imageView) {
        _imageView = [[UIImageView alloc]init];
        _imageView.backgroundColor = [UIColor clearColor];
        _imageView.image = [UIImage imageNamed:@"list_pic"];
    }
    return _imageView;
}
- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.font = DEF_FontSize_14;
        _titleLabel.textColor = getColor(blackColor);
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.text = @"货运";
    }
    return _titleLabel;
}
@end
